package com.axing.springbootinit.service.impl.inner;

import com.alibaba.nacos.common.utils.StringUtils;
import com.axing.model.entity.User;
import com.axing.service.InnerUserService;
import com.axing.springbootinit.common.ErrorCode;
import com.axing.springbootinit.exception.BusinessException;
import com.axing.springbootinit.mapper.UserMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
@DubboService
public class InnerUserServiceImpl implements InnerUserService {
        @Resource
        private UserMapper userMapper;


    @Override
    public User getInvokeUser(String accessKey) {
        if(StringUtils.isAnyBlank(accessKey)){
            throw  new BusinessException(ErrorCode.PARAMS_ERROR);
        }

        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("accessKey", accessKey);
        User user = (User) userMapper.selectOne(userQueryWrapper);
        return user;
    }
}
